package com.wjs.juc.Interrupt;

import java.util.concurrent.TimeUnit;

public class InterruptDemo2 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            for (int i = 1; i <= 300; i++) {
                System.out.println("结果:"+i);
            }
            System.out.println("t1  第二次:"+Thread.currentThread().isInterrupted());
        }, "t1");
        t1.start();
        System.out.println("t1 默认:"+t1.isInterrupted());
        TimeUnit.MILLISECONDS.sleep(200);
        t1.interrupt();
        System.out.println("t1  第一次:"+t1.isInterrupted());
        TimeUnit.SECONDS.sleep(1);
        System.out.println("t1  第三次:"+t1.isInterrupted());
    }
}
